#include <stdio.h>
#include "studentList.h"
#include "draw.h"
#include "read.h"
#include "save.h"

int main()
{
    STUDENT *head = creat_list();
    STUDENT *node;
	FILE *fp = fopen("studentDate.xml", "r");
	read_student_data_from_file(head, fp);
	fclose(fp);
	Menu_init();
    int opt;
	while(1)
    {
		printf("请输入菜单选项:");
		scanf("%d", &opt);
		getchar();
		switch (opt)
        {
			case 1:
				//新增学生基本信息
                node = creat_node_by_basic_information("17211164123", "潘森", "123456");
                insert_node(head, node);
                node = creat_node_by_basic_information("17211164124", "艾克", "123457");
                insert_node(head, node);
				break;
			case 2:
				//显示所有学生基本信息
                Interface_basic_info();
				display_all_basic_information(head);
                Interface_basic_info2();
				break;
			case 3:
				//修改学生电话号码
                change_phone_number(head, "艾克", "654321");
				break;
			case 4:
				//删除学生信息
                del_node_by_name(head, "潘森");
				del_node_by_name(head, "艾克");
				break;
			case 5:
				// 添加学生成绩
                insert_stuNode_score(head, "艾克", 90, 90, 90);
                insert_stuNode_score(head, "潘森", 80, 90, 90);
				break;
			case 6:
				// 显示所有学生成绩
                Interface_score();
				display_all_scores(head);
                Interface_score2();
				break;
			case 7:
				//查找学生基本信息
                node = find_node_by_name(head, "艾克");
                Interface_basic_info();
                display_basic_information(node);
                printf("\n");
                Interface_basic_info2();
				break;
			default :
				break;
		}
		if (opt == 0)
        {
			FILE *fp = fopen("studentDate.xml", "w");
			Save_Student_Data(head, fp);
			fclose(fp);
			break;
		}
	}
    destory_list(&head);
    return 0;
}